import Vue from 'vue'
import VueRouter from 'vue-router'
import {
  routerList,
  subRouter
} from "./routerModule"



// 解决路径冲突的问题
const original = VueRouter.prototype.push;
VueRouter.prototype.push = (location) => {
  return original.call(this, location).catch(err => err)
}




Vue.use(VueRouter)


const routes = [
  // 登录页面
  {
    name: "login",
    component: () => import('../views/login.vue'),
    path: "/login"
  },
  // 首页
  {
    name: "index",
    component: () => import("../layout/index.vue"),
    path: "/",
    redirect: "/",
    children: [...routerList, ...subRouter]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router